package com.qfedu.controller;

import com.qfedu.common.JsonResult;
import com.qfedu.entity.User;
import com.qfedu.utils.StrUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @Author 刘浩
 * @Date 2020/8/24 11:56
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/query.do")
    @ResponseBody
    public JsonResult getLoginInfo(HttpSession session){
        User u = (User)session.getAttribute(StrUtils.LOGIN_USER);
        JsonResult jsonResult=null;
        if (u!=null){
            jsonResult=new JsonResult(1,u);
        }else {
            jsonResult=new JsonResult(0,"用户未登录");
        }
        return jsonResult;
    }
}
